var TouchSwiper = {

    isTouchMove: null,
    startTx: null,
    startTy: null,

    touchStart: function (e) {
        var touches = e.touches[0];

        TouchSwiper.startTx = touches.clientX;
        TouchSwiper.startTy = touches.clientY;
        TouchSwiper.isTouchMove = false;
    },

    touchMove: function (e) {
        TouchSwiper.isTouchMove = true;
        e.preventDefault();
    },

    touchEnd: function (e) {
    if (!TouchSwiper.isTouchMove) {
        return;
    }

    var touches = e.changedTouches[0],
        endTx = touches.clientX,
        endTy = touches.clientY,
        distanceX = TouchSwiper.startTx - endTx,
        distanceY = TouchSwiper.startTy - endTy,
        isSwipe = false;

    if(Math.abs(distanceX) >= Math.abs(distanceY)){
        if (distanceX > 20){
            console.log('fire swipe left event');
            isSwipe = true;
        }else if (distanceX < -20){
            console.log('fire swipe right event');
            isSwipe = true;
        }
    }else {
        if (distanceY > 20){
            console.log('fire swipe up event');
            isSwipe = true;
        }else if (distanceY < -20){
            console.log('fire swipe down event');
            isSwipe = true;
        }
    }

    if (isSwipe){
        console.log('fire swipe event');
    }
    }
};